package com.example.tool.util.aliyun;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
public enum AliYunTrackTypeEnum {
    //COLLECTION 揽收, SENDER 发件,RECEIVED 到件,DELIVERY 派件,ARRIVAL 代收,TRANSFER_ORDER 转单,GIVEBACK 退回,SIGNED 签收
    NOT_COLLECTED("NOT_COLLECTED", "未知"),
    RECEIVE("RECEIVE", "接单中"),
    WAIT_ACCEPT("WAIT_ACCEPT", "待揽收"),
    ACCEPT("ACCEPT", "揽收"),
    TRANSPORT("TRANSPORT", "运输中"),
    ON_THE_WAY("ON_THE_WAY", "在途中"),
    SEND_ON("SEND_ON", "转单或修改地址转寄"),
    ARRIVE_CITY("ARRIVE_CITY", "到达目的城市"),
    DELIVERING("DELIVERING", "派件中"),
    STA_INBOUND("STA_INBOUND", "已放入快递柜或驿站"),
    AGENT_SIGN("AGENT_SIGN", "已代签收"),
    SIGN("SIGN", "已签收"),
    STA_SIGN("STA_SIGN", "从快递柜或者驿站取出"),
    RETURN_SIGN("RETURN_SIGN", "退回签收"),
    FAILED("FAILED", "包裹异常"),
    TIMEOUT_UNSIGEN("TIMEOUT_UNSIGEN", "超时未签收"),
    TIMEOUT_NO_UPDATE("TIMEOUT_NO_UPDATE", "超时未更新"),
    REFUSE_SIGN("REFUSE_SIGN", "拒收"),
    DELIVER_ABNORMAL("DELIVER_ABNORMAL", "派件异常"),
    STA_TIMEOUT_UNSIGEN("STA_TIMEOUT_UNSIGEN", "快递柜或者驿站超时未取"),
    CONTACT_FAIL("CONTACT_FAIL", "无法联系"),
    OVER_AREA("OVER_AREA", "超区"),
    RETENTION("RETENTION", "滞留件"),
    ISSUE("ISSUE", "问题件"),
    RETURN("RETURN", "退回件"),
    SEND_NO_MESSAGE("SEND_NO_MESSAGE", "发货无信息"),
    DAMAGE("DAMAGE", "破损"),
    CANCEL_ORDER("CANCEL_ORDER", "揽件取消"),
    SIGNED("SIGN", "签收");
    private final String code;
    private final String description;

    AliYunTrackTypeEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public static String byTypeGetDescription(String code){
        Optional<AliYunTrackTypeEnum> first = Arrays.stream(AliYunTrackTypeEnum.values()).filter(e -> ObjectUtil.equals(e.code, code)).findFirst();
        if (first.isPresent()) {
         return first.get().description;
        }
        return "";
    }

//    public static void main(String[] args) {
//        System.out.println(byTypeGetDescription(""));
//        System.out.println(byTypeGetDescription("ARRIVAL"));
//    }
}
